import urllib.request
import urllib.parse
import json

url = "https://www.baidu.com/s?ie=UTF-8&wd=ip"

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36'
}

request = urllib.request.Request(url=url, headers=headers)
# 模拟浏览器访问服务器
proxies = {
    "http":"118.24.219.151:16817",
}
handler =  urllib.request.ProxyHandler(proxies=proxies)
opener = urllib.request.build_opener(handler)
response = opener.open(request)

content = response.read().decode("utf-8")
with open("daili.html", "w", encoding="utf-8") as fp:
    fp.write(content)
fp.close()